﻿using Basic.WxModel.DB;
using Basic.WxModel.WxMer;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.IdGenerator;
using WeDonekRpc.SqlSugar;

namespace Basic.WxRepository.lmpl
{
    internal class WxMerRepository : WxBasicRepository<DBWxMer, long>, IWxMerRepository
    {
        public WxMerRepository (ISqlClientFactory factory) : base(factory)
        {
        }

        public DBWxMer Add (WxMerAdd add)
        {
            DBWxMer data = add.ConvertMap<WxMerAdd, DBWxMer>();
            data.Id = IdentityHelper.CreateId();
            data.AddTime = DateTime.Now;
            base.Insert(data);
            return data;
        }
        public long FindWxMerId (string wxAppId)
        {
            return base.Get<long>(a => a.AppId == wxAppId, c => c.Id);
        }
        public DBWxMer FindWxMer (string wxAppId)
        {
            return base.Get(a => a.AppId == wxAppId);
        }
    }
}
